/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xyrelationship.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xyrelationship.param.XyRelationshipParam;
import vip.xiaonuo.modular.xyrelationship.service.XyRelationshipService;
import vip.xiaonuo.modular.xyrelationship.entity.XyRelationship;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 族员关系控制器
 *
 * @author yanwei
 * @date 2023-05-06 14:15:26
 */
@RestController
@Api(tags = "后台管理 族员关系 相关APIS")
@AdminVersionSwagger
public class XyRelationshipController {

    @Resource
    private XyRelationshipService xyRelationshipService;

    /**
     * 查询族员关系
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @GetMapping("/xyRelationship/page")
    @BusinessLog(title = "族员关系_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("族员关系_查询")
    public Result<PageResult<XyRelationship>> page(XyRelationshipParam xyRelationshipParam) {
        PageResult<XyRelationship> page = xyRelationshipService.page(xyRelationshipParam);
        return success(page);
    }

    /**
     * 添加族员关系
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @PostMapping("/xyRelationship/add")
    @BusinessLog(title = "族员关系_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("族员关系_增加")
    public Result add(@RequestBody @Validated(XyRelationshipParam.add.class) XyRelationshipParam xyRelationshipParam) {
            xyRelationshipService.add(xyRelationshipParam);
        return success();
    }

    /**
     * 删除族员关系，可批量删除
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @PostMapping("/xyRelationship/delete")
    @BusinessLog(title = "族员关系_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("族员关系_删除")
    public Result delete(@RequestBody @Validated(XyRelationshipParam.delete.class) List<XyRelationshipParam> xyRelationshipParamList) {
            xyRelationshipService.delete(xyRelationshipParamList);
        return success();
    }

    /**
     * 编辑族员关系
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @PostMapping("/xyRelationship/edit")
    @BusinessLog(title = "族员关系_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("族员关系_编辑")
    public Result edit(@RequestBody @Validated(XyRelationshipParam.edit.class) XyRelationshipParam xyRelationshipParam) {
            xyRelationshipService.edit(xyRelationshipParam);
        return success();
    }

    /**
     * 查看族员关系
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @GetMapping("/xyRelationship/detail")
    @BusinessLog(title = "族员关系_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("族员关系_查看")
    public Result<XyRelationship> detail(@Validated(XyRelationshipParam.detail.class) XyRelationshipParam xyRelationshipParam) {
        XyRelationship detail =   xyRelationshipService.detail(xyRelationshipParam);
        return success(detail);
    }

    /**
     * 族员关系列表
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @GetMapping("/xyRelationship/list")
    @BusinessLog(title = "族员关系_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("族员关系_列表")
    public Result<List<XyRelationship>> list(XyRelationshipParam xyRelationshipParam) {
        List<XyRelationship> list  =   xyRelationshipService.list(xyRelationshipParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-06 14:15:26
     */
    @Permission
    @GetMapping("/xyRelationship/export")
    @BusinessLog(title = "族员关系_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("族员关系_导出")
    public void export(XyRelationshipParam xyRelationshipParam) {
        xyRelationshipService.export(xyRelationshipParam);
    }

}
